package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Slf4j
@Api(tags = "店铺相关接口")
public class ShopController {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @ApiOperation("设置店铺营业状态")
    @PutMapping("/{status}")
    public Result setShopStatus(@PathVariable("status") Integer status){
        stringRedisTemplate.opsForValue().set("Shop_status",status.toString());
        return Result.success();
    }

    @ApiOperation("查看店铺营业状态")
    @GetMapping("/status")
    public Result getShopStatus(){
        return Result.success(Integer.parseInt(stringRedisTemplate.opsForValue().get("Shop_status")));
    }
}
